﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

<script type="text/javascript">
    var searchLand;

    function showSearchLand(tab) {
        searchLand = $("#searchLand");

        var landWidth = $(searchLand).width();
        var offSet = $(tab).offset();
        var height = $(tab).height();
        $(searchLand).fadeIn();
        $(searchLand).offset({ "left": offSet.left, "top": offSet.top + height + 4 });
        $(searchLand).animate({ width: 600, height: 400 }, "slow");
        $(searchLand).children().fadeIn();


        $("#searchText").val("");
        $("#Message").removeAttr("checked");
        $("#wf_form").removeAttr("checked");
        $("#plan_notify").removeAttr("checked");
        $("#wf_template").removeAttr("checked");
        $("#wf_ins").removeAttr("checked");
        $("#wf_task").removeAttr("checked");
    }

    function hideSearchLand() {
        $(searchLand).css("display", "none");
        $(searchLand).children().css("display", "none");
        $(searchLand).width(20);
        $(searchLand).height(20);
    }

    function search_submit() {
        addtab('search', '搜索结果');
        hideSearchLand();
    }

    //    $(function() {
    //        var options = {
    //            type: "POST",
    //            url: '/Home/GlobalSearch',
    //            success: function(data) {
    //                addtab('search', '搜索结果');
    //                $("#workarea-search").html(data);
    //            }
    //        };

    //        $("#glo_search").ajaxForm(options);
    //    });

    function search_render(tabId, searchUrl) {
        var tabName = "搜索结果";
        if (tabId == "3-2")
            tabName = "已发信息";
        else if (tabId == "3-3")
            tabName = "已收信息";
        else if (tabId == "11-1")
            tabName = "公告";
        else if (tabId == "10-2")
            tabName = "流程";
        else if (tabId == "")
            tabName = "";
        addtab(tabId, tabName);

        var button = "<a style='display:none;' id='btnTrigger' onclick='Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event)," +
                    " { insertionMode: Sys.Mvc.InsertionMode.replace,updateTargetId: &apos;workarea-" + tabId + "&apos; });' " +
                    " href='" + searchUrl + "' >显示结果</a>";
        $("#workarea-" + tabId).append(button);
        $("#btnTrigger").trigger('click');
    }
</script>

<input type="button" value="全局搜索" onclick="showSearchLand(this)" />
<div id="searchLand" style="position: absolute; display: none; width: 20px; height: 20px;
    z-index: 9999; border: solid 2px gray; background-color: White;">
    <div style="display: none;">
        <%using (Ajax.BeginForm("GlobalSearch", "Home", new AjaxOptions { UpdateTargetId = "workarea-search" }))
          { %>
        检索对象:
        <br />
        <%=Html.CheckBox("Message")%>信息
        <%=Html.CheckBox("wf_form")%>表单
        <%=Html.CheckBox("plan_notify")%>公告
        <br />
        <%=Html.CheckBox("wf_template")%>流程
        <%--<%=Html.CheckBox("wf_ins")%>申请
        <%=Html.CheckBox("wf_task")%>审批--%>
        <br />
        <%=Html.TextBox("searchText")%>
        <input type="submit" value="搜索" onclick="return search_submit();" />
        <input type="reset" value="取消" onclick="return hideSearchLand();" />
        <%} %>
    </div>
</div>
